ASP. NET uses X509Certificate2 to solve a series of problems,
When you make a refund, because you need to use the p12 certificate, the results encountered a series of pitfalls. Make a record for future reference.
Code for loading the original certificate:
Copy codeThe Code is as follows: 1 X509Certificate2 cert = new X509Certificate2 (path + WxPayConfig. SSLCERT_PATH, WxPayConfig. SSLCERT_PASSWORD); 2 Request. ClientCertificates. Add (cert );
Passed the test on. However, this issue is reported d
First scold, Sina Weibo @#@! , without my consent on the forwarding of a variety of micro-blog, manufacturing garbage, but also do not provide micro-BO bulk deletion function, the rogue behavior, shameful hateful, people spit!Sslclient.javaImportOrg.apache.http.conn.ClientConnectionManager;ImportOrg.apache.http.conn.scheme.Scheme;ImportOrg.apache.http.conn.scheme.SchemeRegistry;Importorg.apache.http.conn.ssl.SSLSocketFactory;Importorg.apache.http.impl.client.DefaultHttpClient;ImportJavax.net.ssl
When you use httpwebrequest to access an SSL-type address https: // XXXX, the error "failed to establish a trust relationship for the SSL/TLS Security Channel (cocould not establish trust relationship for the SSL/TLS Secure Channel)"
I checked msdn and found a solution. For SSL websites, certificates must be provided during connection. If client certificates are not requiredReturns a security confirmation.You can. However, the implementation of this method is different in. NET 1.1 and. NET
(reference1.localwcfclient OBJ = new reference1.localwcfclient ()){OBJ. dowork ();}
5. If WCF is deployed on an IIS Site protected by a security certificate, you also need ignorecertificateerrorhandler to avoid certificate issues.
Using system. net;Using system. net. Security;Using system. Security. cryptography. x509certificates;
Private void tmrtimerstimer_elapsed (Object sender, system. Timers. elapsedeventargs E){If (datetime. Now. Hour> sta
I have searched many places and found the following answers on a foreign website to share with you:
Http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.aspnet/2006-03/msg02317.html
[Open this link in a new window]
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
//
NET 1.0/1.1 version:
//
======================================
Using
System. net;
Using
System. Security. cryptography.
"-services "IIS, POP, IMAP "-DomainController $ RoleDomainController-InstallInTrustedRootCAIfSelfSigned $ true if ($ RoleIsDatacenter-ne $ true-And $ RoleIsPartnerHosted-ne $ true) the following error is generated when {Install-AuthCertificate-DomainController $ RoleDomainController} ":" Microsoft. exchange. management. systemConfigurationTasks. addAcc EssRuleCryptographicException: Due to an encryption exception, the network service cannot be authorized to access the certificate containing the
In normal mode
CloseableHttpClient httpclient == = httpclient.execute(httpMethod);
When the above code is used to access
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to valid certification path to requested target
DefaultTrustManager checkClientTrusted(X509Certificate[] x509Certificates, String s) checkServerTru
(unmanagedtype. lpwstr)]38 public string provname;3940 public uint provtype;4142 Public uint flags;4344 public uint provparam;4546 Public intptr rgprovparam;4748 Public uint keyspec;4950}5152 public Win32 ()53 {54 //55 // todo: add the constructor logic here56 //57}58}59}60
Then write a read method in the CERT class to read the certificate. Note: The pfx file may contain several certificates.
1 using system;2 using system. IO;3 using system. runtime. interopservices;4 using system. Security.
relationship with the remote server ".The certificate must be installed on the CAS Server, but the. net Client does not.You can configure the IIS server and support the https ssl protocol to import the digital certificate of the CAS server in the steps described in Security data exchange, or use the solution described at http://support.microsoft.com/kb/823177/to handle the problem:Implementation Class C # code
Using System. Net;
Using System. Security. Cryptography.
sentence can be solved: "The basic connection has been closed: the trust relationship cannot be established for the SSL/TLS security channel"
18 system. net. servicepointmanager. servercertificatevalidationcallback =
19 delegate (Object OBJ, system. Security. cryptography. x509certificates. x509certificate certificate, system. Security. cryptography. x509certificates. x509chain chain, system. net. Security
(unmanagedtype. lpwstr)]38 public string provname;3940 public uint provtype;4142 Public uint flags;4344 public uint provparam;4546 Public intptr rgprovparam;4748 Public uint keyspec;4950}5152 public Win32 ()53 {54 //55 // todo: add the constructor logic here56 //57}58}59}60
Then write a read method in the CERT class to read the certificate. Note: The pfx file may contain several certificates.
1 using system;2 using system. IO;3 using system. runtime. interopservices;4 using system. Security
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.